#include <bits/stdc++.h>

using namespace std;

const int MAX = 1e4+5;
int n, a[MAX], b[MAX], g[MAX], k[MAX], x, y;
int main()
{
    scanf("%d",&n);
    for(int i = 1;i <=n;i++){
        scanf("%d%d%d%d",&a[i],&b[i],&g[i],&k[i]);
    }
    scanf("%d%d",&x,&y);
    for(int i=n;i>=1;i--){
        if(x<=a[i]+g[i]&&y<=b[i]+k[i]&&x>=a[i]&&y>=b[i])
          {
              cout<<i;
            return 0;}
    }
    cout<<-1;
    return 0;
}
